import pyglet

PRINTED_ERROR = False
def avbin_error():
    global PRINTED_ERROR
    if not PRINTED_ERROR:
        print 'Sound playback requires AVBin (http://code.google.com/p/avbin/)'
        PRINTED_ERROR = True

try:
    music = pyglet.media.Player()
    music.eos_action = 'loop'
    music.queue(pyglet.resource.media("music.ogg", streaming=False))

    ambience = pyglet.media.Player()
    ambience.eos_action = 'loop'
    ambience.queue(pyglet.resource.media("ambience.ogg", streaming=False))

    snarl_clip = pyglet.resource.media("snarl.ogg", streaming=False)
    snarl_p = pyglet.media.Player()
    snarl_p.eos_action = 'pause'


    def start_game():
        music.pause()
        ambience.play()

    def start_menu():
        ambience.pause()
        music.play()

    def snarl():
        snarl_clip.play()

except pyglet.media.MediaException:
    def start_game(): pass
    def start_menu(): pass
    avbin_error()